using System;
using System.Collections.Generic;
using System.Text;

namespace Eve.Data
{
    public class Effect : EveProperty
    {
        private string effectName;
        private int effectCategory;
        private int preExpression;
        private int postExpression;
        private string description;
        private string guid;
        private int graphicId;
        private bool isOffensive;
        private bool isAssistance;
        private int durationAttributeId;
        private int trackingSpeedAttributeId;
        private int dischargeAttributeId;
        private int rangeAttributeId;
        private int falloffAttributeId;
        private bool disallowAutoRepeat;
        private bool published;
        private string displayName;
        private bool isWarpSafe;
        private bool rangeChance;
        private bool electronicChance;
        private bool propulsionChance;
        private int distribution;
        private string sfxName;
        private int npcUsageChanceAttributeId;
        private int npcActivationChanceAttributeId;
        private int fittingUsageChanceAttributeId;

        private Graphic graphic;
        private Attribute duration;
        private Attribute trackingSpeed;
        private Attribute discharge;
        private Attribute range;
        private Attribute falloff;
        private Attribute npcUsageChance;
        private Attribute npcActivationChance;
        private Attribute fittingUsageChance;

        public string Name
        {
            get { return effectName; }
        }
        public int Category
        {
            get { return effectCategory; }
        }
        public int PreExpression
        {
            get { return preExpression; }
        }
        public int PostExpression
        {
            get { return postExpression; }
        }
        public string Description
        {
            get { return description; }
        }
        public string GUID
        {
            get { return guid; }
        }
        public Graphic Graphic
        {
            get
            {
                if (graphic == null)
                    graphic = new Graphic(db, graphicId);
                return graphic;
            }
        }
        public bool IsOffensive
        {
            get { return isOffensive; }
        }
        public bool IsAssistance
        {
            get { return isAssistance; }
        }
        public Attribute Duration
        {
            get
            {
                if (duration == null)
                    duration = new Attribute(db, durationAttributeId);
                return duration;
            }
        }
        public Attribute TrackingSpeed
        {
            get
            {
                if (trackingSpeed == null)
                    trackingSpeed = new Attribute(db, trackingSpeedAttributeId);
                return trackingSpeed;
            }
        }
        public Attribute Discharge
        {
            get
            {
                if (discharge == null)
                    discharge = new Attribute(db, dischargeAttributeId);
                return discharge;
            }
        }
        public Attribute Range
        {
            get
            {
                if (range == null)
                    range = new Attribute(db, rangeAttributeId);
                return range;
            }
        }
        public Attribute Falloff
        {
            get
            {
                if (falloff == null)
                    falloff = new Attribute(db, falloffAttributeId);
                return falloff;
            }
        }
        public bool DisallowAutoRepeat
        {
            get { return disallowAutoRepeat; }
        }
        public bool Published
        {
            get { return published; }
        }
        public string DisplayName
        {
            get { return displayName; }
        }
        public bool IsWarpSafe
        {
            get { return isWarpSafe; }
        }
        public bool RangeChance
        {
            get { return rangeChance; }
        }
        public bool ElectronicChance
        {
            get { return electronicChance; }
        }
        public bool PropulsionChance
        {
            get { return propulsionChance; }
        }
        public int Distribution
        {
            get { return distribution; }
        }
        public string SFXName
        {
            get { return sfxName; }
        }
        public Attribute NPCUsageChance
        {
            get
            {
                if (npcUsageChance == null)
                    npcUsageChance = new Attribute(db, npcUsageChanceAttributeId);
                return npcUsageChance;
            }
        }
        public Attribute NPCActivationChance
        {
            get
            {
                if (npcActivationChance == null)
                    npcActivationChance = new Attribute(db, npcActivationChanceAttributeId);
                return npcActivationChance;
            }
        }
        public Attribute FittingUsageChance
        {
            get
            {
                if (fittingUsageChance == null)
                    fittingUsageChance = new Attribute(db, fittingUsageChanceAttributeId);
                return fittingUsageChance;
            }
        }


        internal Effect(DbDataRow dr)
            : base(dr.Database, EvePropertyType.Effect, dr["effectID"])
        {
            Fill(dr);
        }
        internal Effect(Database db, int id)
            : base(db, EvePropertyType.Effect, id)
        {
            Fill(db.ExecuteSingle("SELECT * FROM dgmEffects WHERE effectID=" + id));
        }

        private void Fill(DbDataRow dr)
        {
            effectName = dr["effectName"];
            effectCategory = dr["effectCategory"];
            preExpression = dr["preExpression"];
            postExpression = dr["postExpression"];
            description = dr["description"];
            guid = dr["guid"];
            graphicId = dr["graphicID"];
            isOffensive = dr["isOffensive"];
            isAssistance = dr["isAssistance"];
            durationAttributeId = dr["durationAttributeID"];
            trackingSpeedAttributeId = dr["trackingSpeedAttributeID"];
            dischargeAttributeId = dr["dischargeAttributeID"];
            rangeAttributeId = dr["rangeAttributeID"];
            falloffAttributeId = dr["falloffAttributeID"];
            disallowAutoRepeat = dr["disallowAutoRepeat"];
            published = dr["published"];
            displayName = dr["displayName"];
            isWarpSafe = dr["isWarpSafe"];
            rangeChance = dr["rangeChance"];
            electronicChance = dr["electronicChance"];
            propulsionChance = dr["propulsionChance"];
            distribution = dr["distribution"];
            sfxName = dr["sfxName"];
            npcUsageChanceAttributeId = dr["npcUsageChanceAttributeID"];
            npcActivationChanceAttributeId = dr["npcActiviationChanceAttributeID"];
            fittingUsageChanceAttributeId = dr["fittingUsageChanceAttributeID"];
        }
    }
}
